'use strict';

const Controller = require('egg').Controller;
const qiniu = require('qiniu');
// private static String ACCESS_KEY = "Ci_VFCYmKwFGWgbIEFxTsGNd69amAaXtwiZr9vIR";
//     private static String SECRET_KEY = "XSQNWYzsdcaiE9r68WyQQj13t1RpjuauMR_vx2JG";
//     public static String BUCKET = "haichuanghui";

//     public final static String QINIU_URL = "http://hch.3vyd.com/";
class QiniuController extends Controller {
  async getQiniuToken() {
    const accessKey = 'Ci_VFCYmKwFGWgbIEFxTsGNd69amAaXtwiZr9vIR';
    const secretKey = 'XSQNWYzsdcaiE9r68WyQQj13t1RpjuauMR_vx2JG';
    const mac = new qiniu.auth.digest.Mac(accessKey, secretKey);

    const options = {
      scope: 'posture-camera',
    };
    const putPolicy = new qiniu.rs.PutPolicy(options);
    const uploadToken = putPolicy.uploadToken(mac);
    this.ctx.body = {
      code: 0,
      message: 'OK',
      data: uploadToken,
    };

    // await this.ctx.model.User.findAll();
    // await ctx.service.test.getUserInfo('000000006347c164016348820b040000');
  }
}

module.exports = QiniuController;
